import { createRouter, createWebHashHistory } from 'vue-router'
const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login'
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginView.vue'),
      meta: {
        hasLogin: false
      }
    },
    {
      path: '/',
      name: 'homeLayout',
      component: () => import('../layout/IndexLayout.vue'),
      children: [
        {
          path: 'home',
          name: 'index',
          component: () => import('../views/project/IndexView.vue'),
          meta: {
            hasLogin: true
          }
        },
        {
          path: 'user',
          name: 'user',
          component: () => import('../views/user/IndexView.vue'),
          meta: {
            hasLogin: true
          }
        },
        {
          path: 'dept',
          name: 'dept',
          component: () => import('../views/dept/IndexView.vue'),
          meta: {
            hasLogin: true
          }
        },
        {
          path: 'projectTemplate/:id',
          name: 'projectTemplate',
          component: () => import('../views/projectTemplate/IndexView.vue'),
          meta: {
            hasLogin: true
          }
        },
        {
          path: 'projectTemplateConfiguration/:id',
          name: 'projectTemplateConfiguration',
          component: () => import('../views/projectTemplateConfiguration/IndexView.vue'),
          meta: {
            hasLogin: true
          }
        },

        {
          path: '/updatePassword',
          name: 'updatePassword',
          component: () => import('../views/UpdatePassword.vue'),
          meta: {
            hasLogin: true
          }
        }
      ]
    },
    {
      path: '/404',
      name: 'error404',
      component: () => import('../views/404View.vue'),
      meta: {
        hasLogin: false
      }
    },
    // {
    //   path: '/expiration',
    //   name: 'expiration',
    //   component: () => import('../views/ExpirationView.vue'),
    //   meta: {
    //     hasLogin: false
    //   }
    // },
    {
      path: '/:catchAll(.*)',
      redirect: '/404',
      name: 'NotFound'
    }
  ]
})

export default router
